from os import listdir
from os.path import isfile

#=========================================================================
 
def scandirs(path):
    '''get info of each file ''' 
    for dir in listdir(path):
#        dir = "/".join([path,dir])
        if isfile("/".join([path,dir])):
            logger.info([dir,"/".join([path,dir])])
        else:
            scandirs("/".join([path,dir]))

#=========================================================================

def initlog(logfile):
    '''using log '''
    import logging
    
    logger = logging.getLogger()
    hdlr = logging.FileHandler(logfile)
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr)
    logger.setLevel(logging.NOTSET)
    
    return logger

#=========================================================================

if __name__  == "__main__":
    
    logger = initlog("/tmp/scandir.log")
    scandirs("/root/Desktop/qq")